﻿using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VioletDevelopmentLaboratory.Net.Web;
using VioletDevelopmentLaboratory.Net.Web.Component;

public partial class vboard_component_board_template_default_information_sub : BoardSubPartBase
{
	protected String getTemplateInfomationHtml()
	{
		String templateName = this.Page.Items["Template"].ToString() ?? "default";

		System.Xml.XPath.XPathDocument xdoc = new System.Xml.XPath.XPathDocument(String.Format(System.IO.Path.Combine(VUtility.WebApplicationPhysicalPath, @"vboard\component\board\template\{0}\author.xml"), templateName));

		System.Xml.XPath.XPathNavigator xnav = xdoc.CreateNavigator();

		String name = xnav.SelectSingleNode("author/name").Value;
		String contact = xnav.SelectSingleNode("author/url").Value;
		String version = xnav.SelectSingleNode("author/version").Value;
		String description = xnav.SelectSingleNode("author/description").Value;

		return String.Format(VUtility.GetVWebGlobalResource("General_Script_AuthorInfo"),
			"Template", name, contact, version, description);
	}

	protected String getStylesheetInformationHtml()
	{
		String stylesheetName = this.Page.Items["Stylesheet"].ToString() ?? "default";

		System.Xml.XPath.XPathDocument xdoc = new System.Xml.XPath.XPathDocument(String.Format(System.IO.Path.Combine(VUtility.WebApplicationPhysicalPath, @"vboard\component\board\stylesheet\{0}\author.xml"), stylesheetName));

		System.Xml.XPath.XPathNavigator xnav = xdoc.CreateNavigator();

		String name = xnav.SelectSingleNode("author/name").Value;
		String contact = xnav.SelectSingleNode("author/url").Value;
		String version = xnav.SelectSingleNode("author/version").Value;
		String description = xnav.SelectSingleNode("author/description").Value;

		return String.Format(VUtility.GetVWebGlobalResource("General_Script_AuthorInfo"),
			"Stylesheet", name, contact, version, description);
	}

	protected String getBoardInfomationHtml()
	{
		String sysops = "";

		if (CurrentBoard.SysopCollection != null)
		{
			foreach (Sysop sysop in CurrentBoard.SysopCollection)
			{
				sysops += sysop.UserName + ", ";
			}
			sysops = sysops.Substring(0, sysops.Length - 2);
		}

		String yestText = GetLocalResourceObject("Info_Yes_Text").ToString();
		String noText = GetLocalResourceObject("Info_No_Text").ToString();

		return String.Format(
			VUtility.GetVWebGlobalResource("Board__Script_Info"),
			GetLocalResourceObject("Info_Name_Text"),
			CurrentBoard.Name,
			GetLocalResourceObject("Info_Sysops_Text"),
			sysops,
			GetLocalResourceObject("Info_Symbol_Text"),
			String.Format("<div><img src=\"{0}\" alt=\"\" />&nbsp;{1}&nbsp;&nbsp;<img src=\"{2}\" alt=\"\" />&nbsp;{3}&nbsp;&nbsp;<img src=\"{4}\" alt=\"\" />&nbsp;{5}&nbsp;&nbsp;<img src=\"{6}\" alt=\"\" />&nbsp;{7}&nbsp;&nbsp;<img src=\"{8}\" alt=\"\" />&nbsp;{9}&nbsp;&nbsp;<img src=\"{10}\" alt=\"\" />&nbsp;{11}</div><div><img src=\"{12}\" alt=\"\" />&nbsp;{13}&nbsp;&nbsp;<img src=\"{14}\" alt=\"\" />&nbsp;{15}&nbsp;&nbsp;<img src=\"{16}\" alt=\"\" />&nbsp;{17}&nbsp;&nbsp;<img src=\"{18}\" alt=\"\" />&nbsp;{19}&nbsp;&nbsp;<img src=\"{20}\" alt=\"\" />&nbsp;{21}&nbsp;&nbsp;<img src=\"{22}\" alt=\"\" />&nbsp;{23}</div>",
				ResolveClientUrl(GetLocalResourceObject("Symbol_Stress_Normal_ImageUrl").ToString()),
				GetLocalResourceObject("Symbol_Stress_Normal_Text"),
				ResolveClientUrl(GetLocalResourceObject("Symbol_Stress_Today_ImageUrl").ToString()),
				GetLocalResourceObject("Symbol_Stress_Today_Text"),
				ResolveClientUrl(GetLocalResourceObject("Symbol_Stress_New_ImageUrl").ToString()),
				GetLocalResourceObject("Symbol_Stress_New_Text"),
				ResolveClientUrl(GetLocalResourceObject("Symbol_Stress_Hot_ImageUrl").ToString()),
				GetLocalResourceObject("Symbol_Stress_Hot_Text"),
				ResolveClientUrl(GetLocalResourceObject("Symbol_Stress_Secret_ImageUrl").ToString()),
				GetLocalResourceObject("Symbol_Stress_Secret_Text"),
				ResolveClientUrl(GetLocalResourceObject("Symbol_Stress_Anno_ImageUrl").ToString()),
				GetLocalResourceObject("Symbol_Stress_Anno_Text"),
				ResolveClientUrl(GetLocalResourceObject("Symbol_Att_Link_ImageUrl").ToString()),
				GetLocalResourceObject("Symbol_Att_Link_Text"),
				ResolveClientUrl(GetLocalResourceObject("Symbol_Att_File_ImageUrl").ToString()),
				GetLocalResourceObject("Symbol_Att_File_Text"),
				ResolveClientUrl(GetLocalResourceObject("Symbol_Att_Flash_ImageUrl").ToString()),
				GetLocalResourceObject("Symbol_Att_Flash_Text"),
				ResolveClientUrl(GetLocalResourceObject("Symbol_Att_Image_ImageUrl").ToString()),
				GetLocalResourceObject("Symbol_Att_Image_Text"),
				ResolveClientUrl(GetLocalResourceObject("Symbol_Att_Audio_ImageUrl").ToString()),
				GetLocalResourceObject("Symbol_Att_Audio_Text"),
				ResolveClientUrl(GetLocalResourceObject("Symbol_Att_Video_ImageUrl").ToString()),
				GetLocalResourceObject("Symbol_Att_Video_Text")
			),
			GetLocalResourceObject("Info_UserAuthorized_Text"),
			String.Format("<div>{0} ({1})&nbsp;&nbsp;{2} ({3})</div><div>{4} ({5})&nbsp;&nbsp;{6} ({7})&nbsp;&nbsp;{8} ({9})&nbsp;&nbsp;{10} ({11})</div><div>{12} ({13})&nbsp;&nbsp;{14} ({15})</div>",
				GetLocalResourceObject("Info_ListView_Text"),
				CurrentUserInfo.IsAuthorizedBy(CurrentBoard, BoardCommand.ListView) ? yestText : noText,
				GetLocalResourceObject("Info_Read_Text"),
				CurrentUserInfo.IsAuthorizedBy(CurrentBoard, BoardCommand.Read) ? yestText : noText,
				GetLocalResourceObject("Info_AnnoWrite_Text"),
				CurrentUserInfo.IsAdministrator || CurrentUserInfo.IsSysop(CurrentBoard) || CurrentUserInfo.IsAuthorizedBy(CurrentBoard, BoardCommand.AnnoWrite) ? yestText : noText,
				GetLocalResourceObject("Info_ThreadWrite_Text"),
				CurrentUserInfo.IsAuthorizedBy(CurrentBoard, BoardCommand.ThreadWrite) ? yestText : noText,
				GetLocalResourceObject("Info_ReplyWrite_Text"),
				CurrentUserInfo.IsAuthorizedBy(CurrentBoard, BoardCommand.ThreadReplyWrite) ? yestText : noText,
				GetLocalResourceObject("Info_CommentWrite_Text"),
				CurrentUserInfo.IsAuthorizedBy(CurrentBoard, BoardCommand.CommentWrite) ? yestText : noText,
				GetLocalResourceObject("Info_FileAttachment_Text"),
				CurrentUserInfo.IsAdministrator || CurrentUserInfo.IsSysop(CurrentBoard) || CurrentUserInfo.IsAuthorizedBy(CurrentBoard, BoardCommand.FileUpload) ? yestText : noText,
				GetLocalResourceObject("Info_FileDownload_Text"),
				CurrentUserInfo.IsAuthorizedBy(CurrentBoard, BoardCommand.FileDownload) ? yestText : noText
			),
			GetLocalResourceObject("Info_WebBrowser_Text"),
			"<script type=\"text/javascript\">document.write(navigator.userAgent);</script>"
		);
	}



	protected void Page_Load(object sender, EventArgs e)
	{
		AdminLink.Visible = CurrentUserInfo.IsAdministrator;
	}

	protected void SearchButton_Click(Object sender, EventArgs e)
	{
		//찾기 결과로 이동
		Response.Clear();
		Response.Redirect(BoardUtil.GetBoardUrl(BoardPart.List, 0, "", "", SearchTextBox.Text, 0, 0), true);
	}
}
